<?php
/**
 * CommonMembersProfile
 *  
 * @author x
 * @version 
 */
class Model_CommonMembersProfile extends Zend_Db_Table_Abstract
{
    /**
     * The default table name
     */
    protected $_name = 'tcl_common_members_profile';
    
    
    public function setProfile($data) {
        
        $db = $this->getAdapter();
        $core = new Model_Core();
        $member = $core->isLogin();
        
        $where = $db->quoteInto('uid = ?', $member[uid]);        
        try {
            $id = $this->update($data, $where);
        } catch(Exception $e) {
            // when it fails to insert
            // how can i run this echo
            echo $e; //??
            exit();
        }
        return $id;
    }
    
    
    
    public function getProfile($uid){

        
        $db = $this->getAdapter();
        //$select = $db->select();
        try {
            $row = $this->find($uid)->toArray();
        } catch (Exception $e) {
            echo $e;
            exit();
        }
        
        return $row[0];
    }
    
    
    
    //注册时写入初始化
    public function setNewProfile($data) {
    	
        try {
        	$id = $this->insert($data);
        } catch(Exception $e) {
        	// when it fails to insert
        	// how can i run this echo
        	echo $e; //??
        	exit();
        }
        return $id;
    }
}
